package com.freewater.parking.domain.parking;

import com.freewater.parking.domain.common.Command;
import com.freewater.parking.domain.common.PlateNumber;
import org.apache.commons.lang3.Validate;

import java.time.LocalDateTime;
import java.util.Objects;

public class NotifyPayCommand implements Command {
    /**
     * 车牌号
     */
    private final PlateNumber plateNumber;
    /**
     * 支付时间
     */
    private final LocalDateTime payTime;
    /**
     * 支付金额
     */
    private final int amount;

    public NotifyPayCommand(PlateNumber plateNumber,
                            LocalDateTime payTime,
                            int amount) {
        Validate.notNull(plateNumber, "车牌号不能为空");
        Validate.notNull(payTime, "支付时间不能为空");
        Validate.isTrue(amount >= 0, "支付金额不能为负");
        this.plateNumber = plateNumber;
        this.payTime = payTime;
        this.amount = amount;
    }

    /**
     * 获取车牌号
     *
     * @return 车牌号
     */
    public PlateNumber getPlateNumber() {
        return plateNumber;
    }

    /**
     * 获取支付时间
     *
     * @return 支付时间
     */
    public LocalDateTime getPayTime() {
        return payTime;
    }

    /**
     * 获取支付金额
     *
     * @return 支付金额
     */
    public int getAmount() {
        return amount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        NotifyPayCommand that = (NotifyPayCommand) o;
        return amount == that.amount &&
                Objects.equals(plateNumber, that.plateNumber) &&
                Objects.equals(payTime, that.payTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(plateNumber, payTime, amount);
    }
}
